package com.hdax.dm.user.controller;

import com.hdax.dm.token.TokenUtil;
import com.hdax.dm.user.service.ContactService;
import com.hdax.dm.utils.CommonResponse;
import com.hdax.dm.utils.ResponseUtil;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/user")
public class ticketbuyerlistController {

    @Autowired
    private ContactService contactService;

    @Autowired
    private TokenUtil tokens;

    @PostMapping("p/ticketbuyerlist")
    public CommonResponse linkusers(HttpServletRequest request) {
        // 获取请求消息中的所有头字段
        String token = request.getHeader("token");
        //解密
        Long userId = Long.parseLong(tokens.token(token));
        return ResponseUtil.returnSuccess(contactService.list(userId));
    }
}
